#include <iostream>

using namespace std;

// cosnt_cast
class TextBlock {
public:
    TextBlock() = default;
    TextBlock(const char *str) : str(string(str)) {}
    const char &operator[](size_t pos) const {
        return str[pos];
    }
    char &operator[](size_t pos) {
        return const_cast<char &>(
                static_cast<const TextBlock &>(*this)[pos]
                );
    }
    friend ostream &operator<<(ostream &out, const TextBlock &tb);
private:
    string str;
};

ostream &operator<<(ostream &out, const TextBlock &tb) {
    out << tb.str;
    return out;
}

int main() {
    const TextBlock ctb = "1hello world";
    TextBlock tb = "2hello world";
    cout << ctb[0] << endl;
    cout << tb[0] << endl;
    tb[0] = '1';
    cout << tb << endl;

    return 0;
}
